// #include "NodeController/NodeControllerManager.h"
// #include <QDebug>
// #include <QTimer>

// NodeControllerManager::NodeControllerManager(QObject* parent)
//     : QObject(parent), socket(new QTcpSocket(this))
// {
//     connect(socket, &QTcpSocket::readyRead, this, &NodeControllerManager::readData);
//     connect(socket, &QTcpSocket::errorOccurred, this, &NodeControllerManager::handleError);
// }

// NodeControllerManager::~NodeControllerManager()
// {
//     socket->disconnectFromHost();
// }

// void NodeControllerManager::connectToNodeController(int nodeId, const QString& host, int port)
// {
//     qDebug() << "Connecting to Node Controller" << nodeId << "at" << host << ":" << port;

//     socket->connectToHost(host, port);
//     if (!socket->waitForConnected(3000))
//     {
//         qDebug() << "Failed to connect to" << host << ":" << port;
//         return;
//     }

//     qDebug() << "Connected to" << host << ":" << port;

//     // Send a request to the node controller (optional)
//     socket->write("GET_DATA\n");
//     socket->flush();

//     // Start timeout timer
//     QTimer::singleShot(5000, this, &NodeControllerManager::timeout);
// }

// void NodeControllerManager::readData()
// {
//     QByteArray data = socket->readAll();
//     qDebug() << "Received data:" << data;

//     QMutexLocker locker(&sharedDataMutex);
//     sharedData[0] = QString(data);  // Assuming a single node for simplicity

//     emit dataReady(sharedData);
// }

// void NodeControllerManager::handleError(QAbstractSocket::SocketError error)
// {
//     qDebug() << "Socket error:" << error << socket->errorString();
// }

// void NodeControllerManager::timeout()
// {
//     qDebug() << "Timeout waiting for data";
//     socket->disconnectFromHost();
// }
